package top.canyue.word_range.pojo.buider;

import top.canyue.word_range.pojo.po.Review;

import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

/**
 * 用于生成一个全新的复习记录
 */

public class ReviewBuilder {

    public static Review buildReview(String userId, String word) {
        // 生成随机 UUID
        String id = UUID.randomUUID().toString();

        // 获取当前日期
        Date reviewDate = new Date();

        // 计算 nextReviewDate = reviewDate + 1 天
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(reviewDate);
        calendar.add(Calendar.DAY_OF_YEAR, 1); // 增加 1 天
        Date nextReviewDate = calendar.getTime();

        // 创建 Review 实例
        Review review = new Review();
        review.setId(id);
        review.setUserId(userId);
        review.setWord(word);
        review.setReviewDate(reviewDate);
        review.setStage(1); // stage 为 1
        review.setNextReviewDate(nextReviewDate);

        return review;
    }
}
